'''
Purpose:    creates a matrix of lagged values

Usage:      z = lag(inMatX,n,v)
Where:       inMatX the input matrix
            n = order of the lag (optional default is 1)
            v = initial value to assign to matrix (optional defualt is 0)

Created on Aug 16, 2010
@author: Peter Harrington
peter.b.harrington@gmail.com
'''
from numpy import *
from trimr import *

def lag(inMatX, n = 1, v = 0):
    zt = multiply(matrix(ones((n,inMatX.shape[1]))),v) #zero term
    z = concatenate((zt,trimr(inMatX,0,n)))
    return z